package com.beney.util;

/**
 * 命令包装工具
 *
 * @author Beney
 */
public class Commands {
    private Commands() {
    }

    public static final String HINT_PRE = "$ ";

    public static final String INPUT_PRE = "> ";

    /**
     * 切换用户的命令前驱
     */
    public static final String ID_COMMAND = "切换为";

    public static final int ID_COMMAND_LEN = ID_COMMAND.length();

    /**
     * 生成一个提示用户输入信息的命令
     *
     * @param com 命令内容
     * @param name 用户名
     * @param identity 用户身份
     * @return 规格化的命令
     */
    public static String wrapHintInputCommand(String name, String identity, String ...com) {
        StringBuilder sb = new StringBuilder(HINT_PRE);
        for (String s : com) {
            sb.append(s);
        }
        sb.append('\n');
        if (!name.equals("")) {
            sb.append(name);
            sb.append('(');
            sb.append(identity);
            sb.append(')');
        }
        sb.append(INPUT_PRE);
        return sb.toString();
    }

    /**
     * 生成一个提示用户的命令
     *
     * @param com 命令内容
     * @return 规格化的命令
     */
    public static String wrapHintCommand(String... com) {
        StringBuilder sb = new StringBuilder(HINT_PRE);
        for (String s : com) {
            sb.append(s);
        }
        sb.append('\n');
        return sb.toString();
    }
}
